import request from '@/utils/request'

// 通过查询条件查询部门列表
export function getFilterDepartment(para) {
  console.log('reqUrl--------------> /department/filter?currentPage=' + para.page + '&pageSize=' + para.size + '&department=' + para.department)
  return request({
    url: '/department/filter?currentPage=' + para.page + '&pageSize=' + para.size + '&department=' + para.department,
    method: 'get'
  })
}

// 查询部门树列表
export function getDepartmentTree() {
  return request({
    url: '/department/getDepartmentTree',
    method: 'get'
  })
}

// 查询部门列表
export function getDepartmentListPage(page, size) {
  console.log('page----> ' + page)
  console.log('pageSize----> ' + size)
  return request({
    url: '/department/list?currentPage=' + page + '&pageSize=' + size,
    method: 'get'
  })
}

// 删除某个部门
export function removeDepartment(para) {
  return request({
    url: '/department/remove',
    method: 'post',
    data: {
      id: para.id
    }
  })
}

// 批量删除部门
export function batchRemoveDepartment(para) {
  console.log('-----------------> ' + para.ids)
  return request({
    url: '/department/batchremove',
    method: 'post',
    data: {
      ids: para.ids
    }
  })
}

// 编辑部门
export function editDepartment(data) {
  return request({
    url: '/department/edit',
    method: 'post',
    data: data
  })
}
// 禁用启用
export function availableDepartment(para) {
  console.log('available.data--------> id ' + para.id + ', available ' + para.available)
  return request({
    url: '/department/available',
    method: 'post',
    data: {
      id: para.id,
      available: para.available
    }
  })
}

// 新增部门
export function addDepartment(data) {
  console.log(data)
  return request({
    url: '/department/add',
    method: 'post',
    data: data
  })
}
